/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.                       */
/*                                                                            */
/*  NAME      = db2_comm.h                                                    */
/*  NOTE      =                                                               */
/*  DATE      = 2015/03/19 by zhengxd                                         */
/******************************************************************************/
#ifndef _DB2_COMM_H_
#define _DB2_COMM_H_

#include "db2_core.h"

void db2_dbg(void);

void db2_free(void **pp_buff);

void db2_node_free(Frlist_node *p_st_node);

void db2_frdata_free(Frdata_field **pp_st_value);

void db2_frdata_node_free(Frlist_node *p_st_node);

void db2_cmd_free(Db2_req_cmd **pp_st_cmd);

void db2_cmd_node_free(Frlist_node *p_st_node);

L7_req_db2* db2_create_request(void);

L7_resp_db2* db2_create_response(void);

void db2_init_fragment(L7_fragment_db2 *p_st_fragment);

void db2_destroy_fragment(L7_fragment_db2 **pp_st_fragment);

void db2_destroy_session(L7session_db2 **pp_st_session);

void db2_destroy_request(L7_req_db2 **pp_st_request);

void db2_destroy_response(L7_resp_db2 **pp_st_resp);

int db2_get_ddm_hd_info(Frbyte_Packet *p_st_data
                       , int i_whole_flg
                       , int *p_i_cp
                       , int *p_i_correlator_flg
                       , unsigned int *p_ui_ddm_bd_len
                       , int *p_i_exter_flg);

int db2_add_req_cmd(L7_req_db2 *p_st_request
                   , int i_req_cmd_cp
                   , long l_cursor_id
                   , int i_new_flg
                   , Sql_statement *p_st_statement
                   , Sql_resultset *p_st_resultset);

int db2_get_ddm_cp(L7_fragment_db2 *p_st_fragment
                  , int i_whole_flg
                  , int *p_i_ddm_cp
                  , unsigned int *p_ui_ddm_len);

int db2_get_obj_cp(L7_fragment_db2 *p_st_fragment
                  , int i_whole_flg
                  , int *p_i_ddm_cp
                  , unsigned int *p_ui_ddm_len);

int db2_skip_ddm(L7_fragment_db2 *p_st_fragment, int i_whole_flg);

int db2_ebcdic_to_ascii(Frbyte_Packet *p_st_data
                       , unsigned int ui_ebcdic_len
                       , char **pp_out_ascii
                       , unsigned int *p_ui_out_len);

int db2_create_session_data(L7session_db2 *p_st_sess
                           , Frlist_header **pp_lst_sess_data);

int db2_typdef_str2int(char *p_typdefnam, int *p_i_typdef);

int db2_get_bindr(Frbyte_Packet *p_st_data
                 , unsigned int ui_bindr_len
                 , int i_whole_flg
                 , int64_t *p_i64_value
                 , unsigned int *p_ui_ddm_left_len);

int db2_get_bytstrdr(Frbyte_Packet *p_st_data
                    , unsigned int ui_bytstrdr_len
                    , int i_whole_flg
                    , char **pp_value
                    , unsigned int *p_ui_ddm_left_len);

int db2_get_chrstrdr(Frbyte_Packet *p_st_data
                    , unsigned int ui_chrstrdr_len
                    , int i_whole_flg
                    , char *p_ccsid
                    , char **pp_value
                    , unsigned int *p_ui_ddm_left_len);

Frreport_body_data* db2_new_report_body(Conntrack *p_st_conn
                                       , L7session_db2 *p_st_sess);

#endif
